<?php
/**
 * Created by PhpStorm.
 * User: ycp
 * Date: 2019/5/23
 * Time: 22:23
 */

namespace app\api\controller;


class Content extends ApiCommon
{
    protected $service;
    protected $slideTable = 'lite_slideshow';

    public function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
       $data = db($this->slideTable)->where(['is_deleted' => 0])->order('sort desc')->select();
       $host = $this->host;
       $res = [];
       foreach ($data as $key => $val){
           switch ($val['type']){
               case 0:
                   $res['swiper'][$key]['type'] = 'image';
                   $res['swiper'][$key]['pic'] = $host. $data[$key]['pic'];
                   $res['swiper'][$key]['url'] = $data[$key]['url'];
                   break;
               case 1:
                   $res['banner'][$key]['pic'] = $host. $val['pic'];
                   $res['banner'][$key]['url'] = $val['url'];
                   break;
               case 2:
                   $res['nav'][$key]['pic'] = $host. $val['pic'];
                   $res['nav'][$key]['url'] = $val['url'];
                   break;
           }
       }
       $this->success('', $res);
    }
}